package com.edu.internship.busi.controller;

import com.edu.internship.busi.service.IDigitCaptchaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * code is far away from bug with the animal protecting
 *
 * @author lishiquan
 * @description
 * @date 2022-07-29
 */
@RestController
@RequestMapping("api/captcha")
@Slf4j
@Api(tags = {"验证码控制器"})
public class DigitCaptchaController {

    @Resource
    private IDigitCaptchaService digitCaptchaService;

    @GetMapping
    @ApiOperation(value = "获取验证码", notes = "获取验证码,并返回")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型1:字母验证码 2:算术验证码", dataTypeClass = String.class, paramType = "query")
    })
    public Map<String, String> digitCaptcha(@RequestParam(required = false, defaultValue = "1") String type) {
        return digitCaptchaService.digitCaptcha(type);
    }

}
